import 'package:flutter/material.dart';
import 'package:jxchmz/%E6%88%91%E7%9A%84/UserCenter.dart';
import 'package:jxchmz/%E9%A6%96%E9%A1%B5/Home.dart';
import 'package:get/get.dart';
class BottomTabbar extends StatefulWidget {
  @override
  _BottomTabbarState createState() => new _BottomTabbarState();
}

class _BottomTabbarState extends State<BottomTabbar>   {
  // TODO: implement wantKeepAlive
  PageController pageController = new PageController();
  //记录当前tabbar点击的下标
  int _currentIndex = 0;
  //存放tabbar
  // List _pageList = ;
  @override
  void initState() {
    super.initState();
  }
  void onPageChanged(int page) {
    setState(() {
      this._currentIndex = page;
    });
  }
  // TODO: add state variables and methods
  @override
  Widget build(BuildContext context) {
    // TODO: add widget build method
    return Scaffold(
      // appBar: AppBar(
      //   backgroundColor: Colors.white,
      //   elevation: 0,
      //   toolbarHeight:0,
      // ),
      body: new PageView(
        physics: new NeverScrollableScrollPhysics(),
        // LikeFishLook(), TanSuo(),
        children: [Home(), UserCenter()],
        controller: pageController,
        onPageChanged: onPageChanged,
      ),
      //创建tabbar
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: this._currentIndex,

        //tabbar的点击事件
        onTap: (int index) {
          pageController.animateToPage(index,
              // 设置页面转换效果的时间
              duration: const Duration(milliseconds: 300),
              // 设置转换时的效果
              curve: Curves.ease);
        },
        //设置图标尺寸
        // iconSize: 25,
        //设置选中图标的颜色
        fixedColor: Color(0xff4990e2),
        //设置item
        items: [
          BottomNavigationBarItem(
            icon: Icon(Icons.home),
            activeIcon: Icon(Icons.home),
            label: "Home".tr,

          ),
          BottomNavigationBarItem(
              icon: Icon(Icons.person),
              label: "My".tr,
              activeIcon: Icon(Icons.person),
          )
        ],
      ),
    );
  }
}
